package com.lingjtx.auth.config;

import com.lingjtx.common.security.limit.ApiContext;
import com.lingjtx.common.thread.config.ObjectPoolTemplateConfig;
import com.lingjtx.common.thread.pooling.ObjectPoolTemplate;
import jakarta.mail.Session;
import jakarta.servlet.http.HttpServletRequest;
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.http.HttpClient;

@Configuration
public class AuthConfig {

    @Bean("httpObjectPoolTemplate")
    public ObjectPoolTemplate<HttpClient> httpObjectPoolTemplate(ObjectPoolTemplateConfig config) {
        return config.httpObjectPoolTemplate();
    }

    @Bean("mailObjectPoolTemplate")
    public ObjectPoolTemplate<Session> mailObjectPoolTemplate(ObjectPoolTemplateConfig config) {
        return config.mailObjectPoolTemplate();
    }

    @Bean("loginOrLogoutContext")
    public ApiContext<ProceedingJoinPoint, HttpServletRequest> apiContext() {
        return new ApiContext<>();
    }
}
